<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欧度男装</title>
    <meta name="keywords" content="欧度男装"/>
    <meta name="description" content="欧度男装"/>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="x-ua-compatible" content="IE=Edge,chrome=1"/>

    <link rel="stylesheet" href="./static/css/swiper.min.css"/>
    <link rel="stylesheet" href="./static/css/amazeui.min.css"/>
    <link rel="stylesheet" href="./static/icomoon/style.css"/>
    <link rel="stylesheet" href="./static/css/common.css"/>
    <link rel="stylesheet" href="./static/css/ouhteu.css"/>

    <meta name="apple-mobile-web-app-title" content="欧度男装"/>
    <script type="text/javascript" src="./static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="./static/js/swiper.min.js"></script>
    <script type="text/javascript" src="./static/js/amazeui.min.js"></script>
    <script type="text/javascript" src="./static/js/common.js"></script>

    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=f6416d403f635ae6931316e5d0aca356&plugin=AMap.Walking"></script>
</head>
<body>
<header class="headerwithback">
    <div class="header_top">
        <a id="goBack"><i class="icon-arrow-left"></i></a>
        <p>门店信息</p>
    </div>    
</header>
<div class="headerHold"></div>
<div class="bl near-shop">
    <i class="icon-location gray">
    </i>距您最近的店：<span class="golden">欧度春熙伊斯丹店</span>
</div>
<div id="container"></div>
<div class="directShop">
    <a id="calc"  class="button normalBt goldenBt"/><i class="icon-location-arrow"></i> 去这家店</a>
</div>
<script type="text/javascript">
    //初始化地图对象，加载地图
    var map, geolocation;
    var localNow = [104.065606,30.657395];
    var shop1 =[104.079425,30.65481];
    var shop2= [104.069898,30.664852];
    map = new AMap.Map("container", {
        resizeEnable: true,
        zoom: 13
    });
    map.setFitView();
    var markers = [{
        position: localNow,
        label:"天府广场店"
    }, {
        position: shop1,
        label:"欧度春熙伊斯丹店"
    }, {
        position: shop2,
        label:"欧度富力店"
    }];
    // 添加一些分布不均的点到地图上,地图上添加三个点标记，作为参照
    markers.forEach(function(marker) {
        new AMap.Marker({
            map: map,
            icon: marker.icon,
            position: [marker.position[0], marker.position[1]],
            offset: new AMap.Pixel(-12, -36)
        }).setLabel({
            offset: new AMap.Pixel(20, 20),
            content: marker.label
        })
    });

    map.plugin('AMap.Geolocation', function() {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,//是否使用高精度定位，默认:true
            timeout: 10000,          //超过10秒后停止定位，默认：无穷大
            buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            buttonPosition:'RB'
        });
        map.addControl(geolocation);
        geolocation.getCurrentPosition();
        AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
        AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
    });
    //解析定位结果
    function onComplete(data) {
        var local = []
        local.push(data.position.getLng());
        local.push(data.position.getLat());
        AMap.event.addDomListener(document.getElementById('calc'), 'click', function() {
            //步行导航
            var walking = new AMap.Walking({
                map: map
            }); 
            //根据起终点坐标规划步行路线
            walking.search(local, shop1);
            
            //计算距离
            //var lnglat = new AMap.LngLat(104.065606,30.657395);
            //alert('你的位置天府广场到 欧度春熙伊斯丹店 的距离为：' + lnglat.distance(shop1) + '米');
            //alert('你的位置天府广场到 欧度富力店 的距离为' + lnglat.distance(shop2) + '米');
        });
    }
    //解析定位错误信息
    function onError(data) {
        alert('定位失败');
    }
</script>
</body>
</html>